package com.dayuanit.dy16.atm.task;

import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling//开启定时器
@EnableAsync //开启异步执行
public class TestTask {

    public TestTask() {
        System.out.println("TestTask()");
    }

    @Scheduled(cron = "0/1 * * * * ?")
//    @Async
    public void helloWorld() {
        System.out.println("Hello world");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    @Scheduled(cron = "0/10 * * * * ?")
    public void transferIn() {
        //给谁加？ 加多少？ 万一重复执行了怎么办？第二步失败了 怎么办？
    }
}
